﻿<base:BaseNavigationPage 
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
           x:Class="WebSiteAdminTool.UI.Views.Security.Users.UserManagementPage" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:base="clr-namespace:WebSiteAdminTool.UI.Views.Base"
           xmlns:vsu="clr-namespace:WebSiteAdminTool.UI.Views.Security.Users"
           xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
           xmlns:behaviors="clr-namespace:WebSiteAdminTool.UI.Utils.Behaviors"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="User Management"
           DataContext="{Binding UserManagementViewModel, Source={StaticResource ViewModelLocator}}">
    <UserControl.Resources>
        <!--<viewModels:MainViewModel x:Key="MainViewModel"/>-->

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Style="{StaticResource PageLayoutStyle}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0">
            <!--DataContext="{StaticResource MainViewModel}"-->
            <TextBlock Style="{StaticResource PageNotesStyle}">
                <Run>Click a row to select a user and then click Edit user to view or change the user's password or other properties. To assign roles to the selected user, select the appropriate check boxes on the right.</Run>
                <LineBreak/>
                <LineBreak/>
                <Run>To prevent a user from logging into your application but retain his or her information in your database, set the status to inactive by clearing the check box.</Run>
            </TextBlock>
            <vsu:UserListFilterPanel DataContext="{Binding UsersListFilter}" />
            <StackPanel x:Name="UsersListContainer">
                <sdk:Label Style="{StaticResource PageSectionHeader}">Application Users</sdk:Label>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*" />
                        <ColumnDefinition Width="120" />
                        <ColumnDefinition Width="120" />
                    </Grid.ColumnDefinitions>
                    <StackPanel Style="{StaticResource UserManagementSearchAlphabetContainer}" Name="pnlAlphabetLinks">
                        <HyperlinkButton Style="{StaticResource UserManagementSearchAlphabetLink}">All</HyperlinkButton>
                        <TextBlock Style="{StaticResource ShadowedElement}">Creating Links ...</TextBlock>
                    </StackPanel>
                    <StackPanel Style="{StaticResource UsersNumberContainer}" Grid.Column="1">
                        <sdk:Label>Found Users:</sdk:Label>
                        <sdk:Label Style="{StaticResource lblUsersNumber}" Content="{Binding NumberOfFoundUsers}" />
                    </StackPanel>
                    <StackPanel Style="{StaticResource UsersNumberContainer}" Grid.Column="2">
                        <sdk:Label>Users Online:</sdk:Label>
                        <sdk:Label Style="{StaticResource lblUsersNumber}" Content="{Binding NumberOfUsersOnline}" />
                    </StackPanel>
                </Grid>
            </StackPanel>
        </StackPanel>
        <sdk:DataGrid Name="UsersDataGrid" Grid.Row="1" Style="{StaticResource ItemsGridStyle}" 
                      ItemsSource="{Binding UsersList}"
                      SelectedItem="{Binding SelectedUser, Mode=TwoWay}">
            <i:Interaction.Behaviors>
                <behaviors:DataGridDoubleClickBehavior
                            DoubleClickCommand="{Binding DoubleClickCommand}" 
                            CommandParameter="{Binding SelectedItem, ElementName=UsersDataGrid}"/>
            </i:Interaction.Behaviors>
            <sdk:DataGrid.Columns>
                <sdk:DataGridCheckBoxColumn Binding="{Binding IsApproved}" CanUserReorder="True" CanUserResize="False" CanUserSort="True" Header="Approved" Width="Auto" />
                <sdk:DataGridCheckBoxColumn Binding="{Binding IsLockedOut}" CanUserReorder="True" CanUserResize="False" CanUserSort="True" Header="Locked" Width="Auto" />
                <sdk:DataGridCheckBoxColumn Binding="{Binding IsOnline}" CanUserReorder="True" CanUserResize="False" CanUserSort="True" Header="Online" Width="Auto" />
                <sdk:DataGridTextColumn Binding="{Binding UserName}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="User Name" Width="Auto" />
                <sdk:DataGridTextColumn Binding="{Binding Email}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="E-Mail" Width="Auto" />
                <sdk:DataGridTextColumn Binding="{Binding LastActivityDate}" CanUserReorder="True" CanUserResize="False" CanUserSort="True" Header="Last Activity" Width="Auto" />
                <sdk:DataGridTextColumn Binding="{Binding UserRoles}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="User Roles" Width="*" />
            </sdk:DataGrid.Columns>
            <!--<i:Interaction.Triggers>
                <i:EventTrigger EventName="SelectionChanged">
                    <i:InvokeCommandAction Command="{Binding UserSelectedCommand}" CommandParameter="{Binding SelectedItems,ElementName=gridUsers}">
                    </i:InvokeCommandAction>
                </i:EventTrigger>
            </i:Interaction.Triggers>-->
        </sdk:DataGrid>
    </Grid>
</base:BaseNavigationPage>
